/*keep all your jquery methods inside this function  to prevent running your jquery code before document loads*/
$(document).ready(function() {

	$("input#school-login-reset").click(function() {
		$('form').clearForm();
	});

	/* Clears form */
	$.fn.clearForm = function() {
		return this.each(function() {
			var type = this.type, tag = this.tagName.toLowerCase();
			if (tag == 'form')
				return $(':input', this).clearForm();
			if (type == 'text' || type == 'password' || tag == 'textarea')
				this.value = '';
			else if (type == 'checkbox' || type == 'radio')
				this.checked = false;
			else if (tag == 'select')
				this.selectedIndex = -1;
		});
	};

	// $("#stateSelector").click(function() {
		// alert("I am an alert box!");
		// });

	});

function getXMLHttpRequestObject() {
	var xmlhttp;
	if (window.XMLHttpRequest) {
		/* code for IE7+, Firefox, Chrome, Opera, Safari */
		xmlhttp = new XMLHttpRequest();
	} else {
		/* code for IE6, IE5 */
		xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
	}
	return xmlhttp;
}

function getCitiesByState() {
	var stateId = document.getElementById("stateSelector").value;

	var xmlhttp = getXMLHttpRequestObject();
	xmlhttp.onreadystatechange = function() {
		if (xmlhttp.readyState == 4 && xmlhttp.status == 200) {
			document.getElementById("aaa").innerHTML = xmlhttp.responseText;
		}
		if (xmlhttp.readyState == 2) {
			document.getElementById("aaa").innerHTML = "22222222222";
		}
		if (xmlhttp.readyState == 3) {
			document.getElementById("aaa").innerHTML = "33333333333";
		}
	}
	xmlhttp.open("POST","http://localhost:8080/bachpan-crm/assets/css/styles.css",true);
	xmlhttp.send();
	// alert(val);
}

/*
 * 
 */
function doGetCaretPosition (ctrl) {
	var CaretPos = 0;	// IE Support
	if (document.selection) {
	ctrl.focus ();
		var Sel = document.selection.createRange ();
		Sel.moveStart ('character', -ctrl.value.length);
		CaretPos = Sel.text.length;
	}
	// Firefox support
	else if (ctrl.selectionStart || ctrl.selectionStart == '0')
		CaretPos = ctrl.selectionStart;
	return (CaretPos);
}

